package com.stu.service.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.stu.mapper.MyorderDetailMapper;
import com.stu.pojo.MyorderDetail;
import com.stu.service.IMyorderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyorderDetailServiceImpl implements IMyorderDetailService {
    @Autowired
    private MyorderDetailMapper myorderDetailMapper;

    @Override
    public List<MyorderDetail> getByMyorderId(Integer myorderId) {
        QueryWrapper<MyorderDetail> wrapper = new QueryWrapper<>();
        wrapper.eq("myorder_id",myorderId);
        List<MyorderDetail> myorderDetails = myorderDetailMapper.selectList(wrapper);
        return myorderDetails;
    }

    @Override
    public Boolean saveMyorderDetail(MyorderDetail myorderDetail) {
        int rows = myorderDetailMapper.insert(myorderDetail);
        return rows>0;
    }

    @Override
    public MyorderDetail getByorderId(Integer orderId) {
        MyorderDetail myorderDetail = myorderDetailMapper.selectById(orderId);
        return myorderDetail;
    }
}
